menubar: Compute proper size even when invisible
authorBenjamin Otte <otte@redhat.com>
Sat, 30 Apr 2011 03:10:55 +0000 (05:10 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 1 May 2011 02:44:56 +0000 (04:44 +0200)
gtk/gtkmenubar.c

index b234b27d18fd626415fbe50f877d28c889e4ba82..d790e31efdf02937772f67a589795600a3569b73 100644 (file)
@@ -312,74 +312,71 @@ gtk_menu_bar_size_request (GtkWidget      *widget,
   requisition->width = 0;
   requisition->height = 0;
   
-  if (gtk_widget_get_visible (widget))
-    {
-      menu_bar = GTK_MENU_BAR (widget);
-      menu_shell = GTK_MENU_SHELL (widget);
-      priv = menu_bar->priv;
+  menu_bar = GTK_MENU_BAR (widget);
+  menu_shell = GTK_MENU_SHELL (widget);
+  priv = menu_bar->priv;
 
-      nchildren = 0;
-      children = menu_shell->priv->children;
+  nchildren = 0;
+  children = menu_shell->priv->children;
 
-      while (children)
-       {
-         child = children->data;
-         children = children->next;
+  while (children)
+    {
+      child = children->data;
+      children = children->next;
 
-         if (gtk_widget_get_visible (child))
-           {
-              gint toggle_size;
+      if (gtk_widget_get_visible (child))
+        {
+          gint toggle_size;
 
-              gtk_widget_get_preferred_size (child, &child_requisition, NULL);
-              gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
-                                                 &toggle_size);
+          gtk_widget_get_preferred_size (child, &child_requisition, NULL);
+          gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
+                                             &toggle_size);
 
-             if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
-                 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
-               child_requisition.width += toggle_size;
-             else
-               child_requisition.height += toggle_size;
+          if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
+              priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
+            child_requisition.width += toggle_size;
+          else
+            child_requisition.height += toggle_size;
 
-              if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
-                 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
-               {
-                 requisition->width += child_requisition.width;
-                 requisition->height = MAX (requisition->height, child_requisition.height);
-               }
-             else
-               {
-                 requisition->width = MAX (requisition->width, child_requisition.width);
-                 requisition->height += child_requisition.height;
-               }
-             nchildren += 1;
-           }
-       }
+          if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
+              priv->pack_direction == GTK_PACK_DIRECTION_RTL)
+            {
+              requisition->width += child_requisition.width;
+              requisition->height = MAX (requisition->height, child_requisition.height);
+            }
+          else
+            {
+              requisition->width = MAX (requisition->width, child_requisition.width);
+              requisition->height += child_requisition.height;
+            }
+          nchildren += 1;
+        }
+    }
 
-      gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
+  gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
 
-      border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
-      requisition->width += (border_width +
-                             ipadding + 
-                            BORDER_SPACING) * 2;
-      requisition->height += (border_width +
-                              ipadding +
-                             BORDER_SPACING) * 2;
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
+  requisition->width += (border_width +
+                         ipadding + 
+                         BORDER_SPACING) * 2;
+  requisition->height += (border_width +
+                          ipadding +
+                          BORDER_SPACING) * 2;
 
-      if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
-       {
-          GtkStyleContext *context;
-          GtkBorder *border;
+  if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
+    {
+      GtkStyleContext *context;
+      GtkBorder *border;
 
-          context = gtk_widget_get_style_context (widget);
+      context = gtk_widget_get_style_context (widget);
 
-          gtk_style_context_get (context, 0,
-                                 "border-width", &border,
-                                 NULL);
+      gtk_style_context_get (context, 0,
+                             "border-width", &border,
+                             NULL);
 
-         requisition->width += border->left + border->right;
-         requisition->height += border->top + border->bottom;
-          gtk_border_free (border);
-       }
+      requisition->width += border->left + border->right;
+      requisition->height += border->top + border->bottom;
+      gtk_border_free (border);
     }
 }